7<template>
	<view>
		<view class="tips text-warning">
			注：如遇紧急情况，使用此功能可将您当前位置信息分享给紧急联系人和护士小鹿客服
		</view>
		
		<view class="address">
			<view class="" style="width: 72rpx;height: 72rpx;margin-right: 24rpx;">
				<image class="address_img" src="../../../static/icon/location/location.png" mode=""></image>
			</view>
			<view class="">
				<view class="title">
					当前参考位置
				</view>
				<view class="detail">
					{{address}}
				</view>
			</view>
			
		</view>
		
		<view class="other">
			<view class="title">
				当您位置分享后，小鹿会：
			</view>
			<view class="list">
				<view class="dot"></view>
				<view class="">
					发送短信，告知紧急联系人您的当前定位
				</view>
			</view>
			<view class="list">
				<view class="dot"></view>
				<view class="">
					发送短信，告知护士小鹿工作人员
				</view>
			</view>
			<view class="warn text-warning">
				温馨提示：请勿恶意重复发送短信
			</view>
		</view>
		<view class="btn" @click="share">
			位置分享
		</view>
		
	</view>
</template>

<script>
	import {callPolice} from  '../../../apis/security/index.js'
	import {selectAllUrgencyLinkman} from '../../../apis/security/index.js'
export default {
        onShow() {
            this.location=this.$store.state.longitude+','+this.$store.state.latitude
			this.init()
        },
        data() {
            return {
                address:this.$store.state.address ,//当前位置
                location:'',//经纬度
				contactList:[],
            }
        },
        methods: {
            // 分享
            async share(){
				if(this.contactList.length>0){
					let res=await callPolice({location:this.location})
					console.log(res,'fenzx..................')
					if(res.success){
						plus.nativeUI.toast('您的当前位置已经成功分享给您的紧急联系人')
						// uni.showToast({
						// 	icon:'none',
						// 	title:'您的当前位置已经成功分享给您的紧急联系人。',
						// })
						setTimeout(()=>{
							uni.switchTab({
								url:'../../tabbars/index/index'
							})
						},300)
					}
				}else{
					plus.nativeUI.toast('请先添加紧急联系人！')
					// uni.showToast({
					// 	icon:'none',
					// 	title:'请先添加紧急联系人！'
					// })
				}
                
                
            },
			async init(){
				let res=await selectAllUrgencyLinkman()
				if(res.success){
					this.contactList=res.object
				}
				console.log(res,'lianxirrrrrr.');
			},
        }
    }
</script>

<style lang="less" scoped>
	.tips{
		padding: 20rpx 26rpx;
		background: #FFF0E5;
		font-size: 28rpx;
		font-weight: 400;
	}
	.address{
		margin: 128rpx 54rpx 0 54rpx;
		box-shadow: 0px 0px 8rpx 0px rgba(0,0,0,0.1);
		border-radius: 20rpx;
		padding: 30rpx 24rpx;
		display: flex;
		align-items: flex-start;
		.title{
			font-size: 32rpx;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.38);
		}
		.address_img{
			width: 72rpx;
			height: 72rpx;
			margin-top: 24rpx;
			display: block;
		}
		.detail{
			font-size: 36rpx;
			font-weight: 500;
			color: #333333;
			margin-top: 8rpx;
		}
	}
	.other{
		padding: 0 54rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 0.87);
		margin-top: 474rpx;
		margin-bottom: 132rpx;
		.list{
			margin-top: 16rpx;
			display: flex;
			align-items: center;
			.dot{
				width: 12rpx;
				height: 12rpx;
				background: rgba(0, 0, 0, 0.5);
				border-radius: 50%;
				margin-right: 24rpx;
			}
			
		}
		.warn{
			margin-top: 16rpx;
			font-size: 24rpx;
		}
	}
	
	.btn{
		position: sticky;
		bottom: 92rpx;
		width: 698rpx;
		height: 96rpx;
		background: #3C8EFF;
		font-size: 36rpx;
		font-weight: 500;
		color: #FFFFFF;
		text-align: center;
		line-height: 96rpx;
		margin-left: 26rpx;
		margin-top: 132rpx;
		box-shadow: 0rpx -6rpx 8rpx 0rpx rgba(0, 0, 0, 0.03);
		
	}

</style>